﻿@model PagedData<ContentSnippet>

@{
	ViewBag.Title = "Content Snippet Index";
}

<div>
	<table style="width: 625px;">
		<tr>
			<td style="width: 48%;">
				<a href="@SiteFilename.ContentSnippetAddEditURL">
					<img class="imgNoBorder" src="~/Assets/Admin/Images/add.png" alt="Add" title="Add as WYSIWYG" />
					Add Content Snippet (with HTML editor)
				</a>
			</td>
			<td>
				&nbsp;
			</td>
			<td style="width: 48%;">
				<a href="@String.Format("{0}?mode=raw", SiteFilename.ContentSnippetAddEditURL)">
					<img class="imgNoBorder" src="~/Assets/Admin/Images/script_add.png" alt="Add" title="Add as Plain Text" />
					Add Content Snippet (as plain text)
				</a>
			</td>
		</tr>
	</table>
</div>
<p>
	<br />
</p>

@using (Html.BeginForm()) {
	@Html.AntiForgeryToken()

	var grid = CarrotWeb.CarrotWebGrid<ContentSnippet>(Model);

	grid.TableAttributes = new { @class = "datatable" };
	grid.THeadAttributes = new { @class = "tablehead" };
	grid.EmptyDataTemplate = @<text><p> <b>No records found.</b> </p></text>;
	grid.ConfigName(Html.NameFor(x => x));

	grid
		.AddColumn(new CarrotGridTemplateColumn<ContentSnippet> {
			HasHeadingText = false,
			FormatTemplate = @<text> @CarrotWeb.ActionImage("ContentSnippetAddEdit", RouteConfig.AdminCtrlr, new { @id = @item.Root_ContentSnippetID }, "~/Assets/Admin/Images/pencil.png", "Edit with WYSIWYG", null, null) </text>
		})
		.AddColumn(new CarrotGridTemplateColumn<ContentSnippet> {
			HasHeadingText = false,
			FormatTemplate = @<text> @CarrotWeb.ActionImage("ContentSnippetAddEdit", RouteConfig.AdminCtrlr, new { @id = @item.Root_ContentSnippetID, @mode = "raw" }, "~/Assets/Admin/Images/script.png", "Edit with Plain Text", null, null) </text>
		})
		.AddColumn(new CarrotGridTemplateColumn<ContentSnippet> {
			HasHeadingText = false,
			FormatTemplate = @<text>
				<a href="javascript:void(0)" onclick="@String.Format("ShowWindowNoRefresh('{0}/{1}')", SiteFilename.ContentSnippetHistoryURL, item.Root_ContentSnippetID)">
					<img src="~/Assets/Admin/Images/hourglass.png" alt="View Page History" title="View Page History" />
				</a>
			</text>
		})
		.AddColumn(x => x.ContentSnippetName, new CarrotGridColumn { Sortable = true })
		.AddColumn(x => x.ContentSnippetSlug, new CarrotGridColumn { Sortable = true })

		.AddColumn(x => x.EditDate, new CarrotGridColumn { Sortable = true, CellFormatString = "{0:M/d/yyyy}" })
		.AddColumn(x => x.GoLiveDate, new CarrotGridColumn { Sortable = true, CellFormatString = "{0:M/d/yyyy}" })
		.AddColumn(x => x.RetireDate, new CarrotGridColumn { Sortable = true, CellFormatString = "{0:M/d/yyyy}" })

		.AddColumn(x => x.IsRetired, new CarrotGridBooleanImageColumn {
			AlternateTextTrue = "Retired",
			AlternateTextFalse = "Active",
			ImagePathTrue = "~/Assets/Admin/Images/clock_red.png",
			ImagePathFalse = "~/Assets/Admin/Images/clock.png",
			Sortable = true
		})
		.AddColumn(x => x.IsUnReleased, new CarrotGridBooleanImageColumn {
			AlternateTextTrue = "Unreleased",
			AlternateTextFalse = "Active",
			ImagePathTrue = "~/Assets/Admin/Images/clock_red.png",
			ImagePathFalse = "~/Assets/Admin/Images/clock.png",
			Sortable = true
		})
		.AddColumn(x => x.ContentSnippetActive, new CarrotGridBooleanImageColumn {
			AlternateTextTrue = "Active",
			AlternateTextFalse = "Inactive",
			Sortable = true
		});

		@grid.Write()
}